home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5067 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. Newsgroups: comp.lang.c
  3. Subject: Re: ANSI var-arglist processing
  4. Message-ID: <danpop.824161793@rscernix>
  5. From: danpop@mail.cern.ch (Dan Pop)
  6. Date: 12 Feb 96 21:49:53 GMT
  7. References: <311B1EF2.7673@exel.co.uk> <4ffuge$j3@spectator.cris.com>
  8. Organization: CERN European Lab for Particle Physics
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4ffuge$j3@spectator.cris.com> Crawford@cris.com (CRAWFORD) writes:
  13.  
  14. >Jason Hambleton <jkh@exel.co.uk> writes:
  15. >>func2(char *fmt, ...)
  16. >>{
  17. >>    va_list args;
  18. >>    char buffer[81];
  19. >>    va_start(args, fmt);
  20. >>    vsprintf(buffer, fmt, args);
  21. >>    va_end(args);
  22. >>    printf("RESULT = (%s)\n", buffer);
  23. >>}
  24. >
  25. >>func1(char *fmt, ...)
  26. >>{
  27. >>    /* How do I pass the arg-list from here, to the next function */
  28. >
  29. >>    func2(fmt, ????????);
  30. >>}
  31. >
  32. >    The answer lies in func2. How did you pass the variable
  33. >argument list to vsprintf?
  34.  
  35. No, the answer isn't there.  The prototype of vsprintf is
  36.  
  37.     int vsprintf(char *s, const char *format, va_list arg);
  38.  
  39. i.e. vsprintf itself is _not_ a variadic function.  OTOH, func2 _is_ a
  40. variadic function.  The real analogy would be to pass the argument list
  41. to sprintf instead of vsprintf and this is not possible (which is the
  42. very reason for the existence of a function like vsprintf).
  43.  
  44. Dan
  45. --
  46. Dan Pop
  47. CERN, CN Division
  48. Email: danpop@mail.cern.ch 
  49. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  50.